// TODO: 获取元素信息
export default class ElementInfo {
  // 获取元素全部尺寸信息
  static async getElementInfo(self, select) {
    return new Promise((resolve, reject) => {
      try {
        let query = wx.createSelectorQuery();
        query = query.in(self);
        let nodeRef = query.select(select);
        query = nodeRef.fields(
          {
            id: true,
            dataset: true,
            mark: true,
            rect: true,
            size: true,
            scrollOffset: true,
            properties: ["scrollX", "scrollY"],
            computedStyle: [
              "padding",
              "border-width",
              "margin",
              "scroll-width",
              "scroll-height",
            ],
            context: true,
            node: true,
          },
          (res) => {
            resolve(res);
          }
        );
        query.exec();
      } catch (error) {
        console.log("获取元素信息失败", error);
        reject(error);
      }
    });
  }
}
